package com.tedu.project5.controller;


import com.tedu.project5.common.Result;
import com.tedu.project5.dto.QueryRoleDTO;
import com.tedu.project5.dto.QueryUserDTO;
import com.tedu.project5.dto.RoleDTO;
import com.tedu.project5.dto.UserDTO;
import com.tedu.project5.model.DdRole;
import com.tedu.project5.model.DdUser;
import com.tedu.project5.service.IDdRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mhg
 * @since 2022-06-13
 */
@Slf4j
@RestController
@RequestMapping("/project5/ddRole")
public class DdRoleController {

    @Autowired
    private IDdRoleService iDdRoleService;
    
    /**
     * 查询角色列表
     * @return
     * http://localhost:9999/project5/ddRole/listAll
     */
    @CrossOrigin
    @PostMapping("/listAll")   
    public Result list(@RequestBody QueryRoleDTO dto){
        log.info("参数值--:"+ dto);
        return iDdRoleService.queryExample(dto);
    }

    /**
     * 新增角色
     * @param role
     * @return
     */
    @CrossOrigin
    @PostMapping("/addRole")
    public Result addUser(@RequestBody DdRole role){
        log.info("参数值--："+ role);
        return iDdRoleService.saveRole(role);
    }

    /**
     * 更新角色信息
     * @param dto
     * @return
     */
    @CrossOrigin
    @PostMapping("/updateById")
    public Result updateById(@RequestBody RoleDTO dto){
        log.info("参数值--："+ dto);
        return iDdRoleService.updateRole(dto);
    }

    /**
     * 删除角色信息
     * @param id
     * @return
     */
    @CrossOrigin
    @PostMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable String id){
        log.info("参数值id--："+ id);
        return iDdRoleService.deleteRole(id);
    }

}
